package bank_access;

import java.io.Serializable;
import mware_lib.ISkeleton;

public class AccountSkeleton implements ISkeleton {
  private AccountImplBase account;
  
  public AccountSkeleton(AccountImplBase accountObject) {
    account = accountObject;
  }
  
  @Override
  public Serializable invokeMethod(String methodName, Serializable[] params) {
    switch (methodName) {
      case "transfer":
        try {
          account.transfer((double)params[0]);
          return null;
        } catch (OverdraftException | RuntimeException e) {
          return e;
        }
      case "getBalance":
        try {
          return (double)account.getBalance();
        } catch(RuntimeException r) {
          return r;
        }
    }
    return null; //Sollte nie erreicht werden!
  }
}
